#pragma once

#include <iostream>
#include <string>
#include <sstream>
#include <locale>
#include <codecvt>
#include "imgui.h"

namespace ImGui
{
	struct StringEditor
	{

		struct Funcs
		{
			static int MyResizeCallback(ImGuiInputTextCallbackData *data)
			{
				if (data->EventFlag == ImGuiInputTextFlags_CallbackResize)
				{
					ImVector<char> *my_str = (ImVector<char> *)data->UserData;
					IM_ASSERT(my_str->begin() == data->Buf);

					my_str->resize(data->BufSize); // NB: On resizing calls, generally data->BufSize == data->BufTextLen + 1
					data->Buf = my_str->begin();
				}
				return 0;
			}

			// Note: Because ImGui:: is a namespace you would typically add your own function into the namespace.
			// For example, you code may declare a function 'ImGui::InputText(const char* label, MyString* my_str)'
			static bool MyInputTextMultiline(const char *label, ImVector<char> *my_str, const ImVec2 &size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0)
			{
				IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0);
				return ImGui::InputTextMultiline(label, my_str->begin(), (size_t)my_str->size(), size,
												 flags | ImGuiInputTextFlags_CallbackResize, Funcs::MyResizeCallback, (void *)my_str);
			}
		};

		bool InputString(const std::string label, std::string &value);

		bool InputMultiString(const std::string label, ImVector<char> &my_str, int row);

		bool InputMultiString(const std::string &label, std::string &value, int row);
		
	};
};